from rest_framework import viewsets
from rest_framework.permissions import AllowAny
from rest_framework.response import Response

from .models import Person
from .serializers import PersonSerializer


class PersonViewSet(viewsets.mixins.ListModelMixin, viewsets.GenericViewSet):
    """
    个人信息视图集，提供CRUD操作。
    """
    queryset = Person.objects.all()
    serializer_class = PersonSerializer
    permission_classes = [AllowAny]

    def list(self, request, *args, **kwargs):
        rsp = super().list(request, *args, **kwargs)
        print(rsp.data, '21212')
        return Response({'persons': rsp.data}, template_name='concatour/index.html')
